# coding=UTF-8
import numpy
import cv2
imagepath=''
face_cascade = cv2.CascadeClassifier('/work/liuwei/model/facedection/haarcascade_frontalface_alt.xml')
img = cv2.imread('/work/temp/face.jpeg')
if img.ndim == 3:
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
else:
    gray = img
faces = face_cascade.detectMultiScale(gray, 1.2, 5)  # 1.3和5是特征的最小、最大检测窗口，它改变检测结果也会改变
result = []
for (x, y, w, h) in faces:
    cv2.rectangle(gray, (x, y), (x+w, y+h), (0, 255, 0), 2) #6
cv2.imshow("Faces found", gray)#7
cv2.waitKey(0) #8


